home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / digitr1a / flashcar.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-07-14  |  14.0 KB  |  449 lines

  1. VERSION 5.00
  2. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
  3. Begin VB.Form Cards 
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Vocabulary Flashcards"
  6.    ClientHeight    =   2730
  7.    ClientLeft      =   150
  8.    ClientTop       =   435
  9.    ClientWidth     =   6030
  10.    BeginProperty Font 
  11.       Name            =   "MS Sans Serif"
  12.       Size            =   8.25
  13.       Charset         =   0
  14.       Weight          =   700
  15.       Underline       =   0   'False
  16.       Italic          =   0   'False
  17.       Strikethrough   =   0   'False
  18.    EndProperty
  19.    Icon            =   "Flashcard.frx":0000
  20.    LinkTopic       =   "Form1"
  21.    MaxButton       =   0   'False
  22.    MinButton       =   0   'False
  23.    ScaleHeight     =   2730
  24.    ScaleWidth      =   6030
  25.    StartUpPosition =   2  'CenterScreen
  26.    Begin MSComDlg.CommonDialog CDialog 
  27.       Left            =   0
  28.       Top             =   0
  29.       _ExtentX        =   847
  30.       _ExtentY        =   847
  31.       _Version        =   393216
  32.       Filter          =   "Vocab Files (*.jfv)|*.jfv|All Files|*.*|"
  33.       InitDir         =   "d:\"
  34.    End
  35.    Begin VB.TextBox txtDefinition 
  36.       BackColor       =   &H8000000B&
  37.       Height          =   765
  38.       Left            =   1200
  39.       Locked          =   -1  'True
  40.       MultiLine       =   -1  'True
  41.       ScrollBars      =   2  'Vertical
  42.       TabIndex        =   3
  43.       TabStop         =   0   'False
  44.       Top             =   975
  45.       Width           =   4815
  46.    End
  47.    Begin VB.TextBox txtWord 
  48.       BackColor       =   &H8000000B&
  49.       Height          =   765
  50.       Left            =   1200
  51.       Locked          =   -1  'True
  52.       MultiLine       =   -1  'True
  53.       ScrollBars      =   2  'Vertical
  54.       TabIndex        =   1
  55.       TabStop         =   0   'False
  56.       Top             =   75
  57.       Width           =   4815
  58.    End
  59.    Begin VB.PictureBox pctFrame 
  60.       BackColor       =   &H8000000B&
  61.       Height          =   450
  62.       Left            =   0
  63.       ScaleHeight     =   390
  64.       ScaleWidth      =   5955
  65.       TabIndex        =   5
  66.       Top             =   2025
  67.       Width           =   6015
  68.       Begin VB.CommandButton cmdNext 
  69.          Caption         =   ">"
  70.          Height          =   315
  71.          Left            =   4725
  72.          TabIndex        =   10
  73.          TabStop         =   0   'False
  74.          Top             =   40
  75.          Width           =   465
  76.       End
  77.       Begin VB.CommandButton cmdShow 
  78.          Caption         =   "Show Definition"
  79.          Default         =   -1  'True
  80.          Height          =   315
  81.          Left            =   1725
  82.          TabIndex        =   9
  83.          Top             =   40
  84.          Width           =   2490
  85.       End
  86.       Begin VB.CommandButton cmdBack 
  87.          Caption         =   "<"
  88.          Height          =   315
  89.          Left            =   750
  90.          TabIndex        =   8
  91.          TabStop         =   0   'False
  92.          Top             =   40
  93.          Width           =   465
  94.       End
  95.       Begin VB.CommandButton cmdLast 
  96.          Caption         =   ">>"
  97.          Height          =   315
  98.          Left            =   5400
  99.          TabIndex        =   7
  100.          TabStop         =   0   'False
  101.          Top             =   40
  102.          Width           =   465
  103.       End
  104.       Begin VB.CommandButton cmdFirst 
  105.          Caption         =   "<<"
  106.          Height          =   315
  107.          Left            =   75
  108.          TabIndex        =   6
  109.          TabStop         =   0   'False
  110.          Top             =   40
  111.          Width           =   465
  112.       End
  113.    End
  114.    Begin VB.Label lblCardPosition 
  115.       Alignment       =   2  'Center
  116.       BackStyle       =   0  'Transparent
  117.       Caption         =   "0 of 0"
  118.       Height          =   240
  119.       Left            =   75
  120.       TabIndex        =   4
  121.       Top             =   1800
  122.       Width           =   5865
  123.    End
  124.    Begin VB.Label lblDefinition 
  125.       AutoSize        =   -1  'True
  126.       BackStyle       =   0  'Transparent
  127.       Caption         =   "Definition:"
  128.       Height          =   195
  129.       Left            =   75
  130.       TabIndex        =   2
  131.       Top             =   975
  132.       Width           =   885
  133.    End
  134.    Begin VB.Label lblWord 
  135.       AutoSize        =   -1  'True
  136.       BackStyle       =   0  'Transparent
  137.       Caption         =   "Word:"
  138.       Height          =   195
  139.       Left            =   75
  140.       TabIndex        =   0
  141.       Top             =   75
  142.       Width           =   525
  143.    End
  144.    Begin VB.Label lblStatus 
  145.       Alignment       =   2  'Center
  146.       BorderStyle     =   1  'Fixed Single
  147.       BeginProperty Font 
  148.          Name            =   "MS Sans Serif"
  149.          Size            =   8.25
  150.          Charset         =   0
  151.          Weight          =   400
  152.          Underline       =   0   'False
  153.          Italic          =   0   'False
  154.          Strikethrough   =   0   'False
  155.       EndProperty
  156.       Height          =   255
  157.       Left            =   -15
  158.       TabIndex        =   11
  159.       Top             =   2475
  160.       Width           =   6045
  161.       WordWrap        =   -1  'True
  162.    End
  163.    Begin VB.Menu mnuFile 
  164.       Caption         =   "&File"
  165.       Begin VB.Menu mnuFileEditor 
  166.          Caption         =   "&Flashcard Editor"
  167.          Shortcut        =   {F5}
  168.       End
  169.       Begin VB.Menu mnuFileLoad 
  170.          Caption         =   "&Load"
  171.          WindowList      =   -1  'True
  172.          Begin VB.Menu mnuFileLoadFlash 
  173.             Caption         =   "&Load Flashcards..."
  174.             Shortcut        =   {F7}
  175.          End
  176.          Begin VB.Menu mnuFileLoadPause1 
  177.             Caption         =   "-"
  178.             Visible         =   0   'False
  179.          End
  180.          Begin VB.Menu mnuFileLoadRecord 
  181.             Caption         =   ""
  182.             Index           =   0
  183.             Visible         =   0   'False
  184.          End
  185.       End
  186.       Begin VB.Menu mnuFileClose 
  187.          Caption         =   "&Close Flashcards"
  188.          Shortcut        =   ^X
  189.       End
  190.       Begin VB.Menu mnuFilePause1 
  191.          Caption         =   "-"
  192.       End
  193.       Begin VB.Menu mnuFileExit 
  194.          Caption         =   "&Exit"
  195.          Shortcut        =   ^C
  196.       End
  197.    End
  198.    Begin VB.Menu mnuDisplay 
  199.       Caption         =   "&Display Options"
  200.       Begin VB.Menu mnuDisplayRevealed 
  201.          Caption         =   "&Revealed"
  202.          Begin VB.Menu mnuDisplayOpt 
  203.             Caption         =   "&Word"
  204.             Checked         =   -1  'True
  205.             Index           =   0
  206.             Shortcut        =   {F1}
  207.          End
  208.          Begin VB.Menu mnuDisplayOpt 
  209.             Caption         =   "&Definition"
  210.             Index           =   1
  211.             Shortcut        =   {F2}
  212.          End
  213.          Begin VB.Menu mnuDisplayOpt 
  214.             Caption         =   "&Both"
  215.             Index           =   2
  216.             Shortcut        =   {F3}
  217.          End
  218.       End
  219.       Begin VB.Menu mnuDisplaySort 
  220.          Caption         =   "&Sort"
  221.          Begin VB.Menu mnuDisplaySortEnt 
  222.             Caption         =   "&By Word"
  223.             Index           =   0
  224.             Shortcut        =   ^W
  225.          End
  226.          Begin VB.Menu mnuDisplaySortEnt 
  227.             Caption         =   "&By Definition"
  228.             Index           =   1
  229.             Shortcut        =   ^D
  230.          End
  231.       End
  232.    End
  233. Attribute VB_Name = "Cards"
  234. Attribute VB_GlobalNameSpace = False
  235. Attribute VB_Creatable = False
  236. Attribute VB_PredeclaredId = True
  237. Attribute VB_Exposed = False
  238. Option Compare Text
  239. Option Explicit
  240. Dim GiveDefinition As Boolean
  241. Dim HiddenBeingShown As Boolean
  242. Sub AddMenuRecord(Record As String, Optional Opening As Boolean)
  243. Dim i As Integer, j As Integer
  244.     If Opening Then
  245.         PrepareFileEntry Record
  246.         If MenuRecords >= 1 Then
  247.             mnuFileLoadRecord(1).Caption = Record
  248.             SaveFileMenuChanges
  249.         Else
  250.             Opening = False
  251.         End If
  252.     End If
  253.     If Not Opening Then
  254.         If MenuRecords = MAXRECORDNUM Then Exit Sub
  255.         MenuRecords = MenuRecords + 1
  256.         Load mnuFileLoadRecord(MenuRecords)
  257.         mnuFileLoadRecord(MenuRecords).Visible = True
  258.         mnuFileLoadRecord(MenuRecords).Caption = Record
  259.     End If
  260.     mnuFileLoadPause1.Visible = True
  261. End Sub
  262. Public Sub ChangeMode(Enabled As Boolean)
  263.     cmdShow.Enabled = Enabled
  264.     cmdNext.Enabled = Enabled
  265.     cmdLast.Enabled = Enabled
  266.     cmdBack.Enabled = Enabled
  267.     cmdFirst.Enabled = Enabled
  268.     txtWord.Enabled = Enabled
  269.     txtDefinition.Enabled = Enabled
  270.     mnuFileClose.Enabled = Enabled
  271.     mnuDisplaySort.Enabled = Enabled
  272. End Sub
  273. Sub ClearData()
  274.     txtWord = ""
  275.     txtDefinition = ""
  276.     lblCardPosition = ""
  277. End Sub
  278. Private Sub cmdBack_Click()
  279.     SetCardPosition CardsPosition - 1
  280. End Sub
  281. Private Sub cmdFirst_Click()
  282.     SetCardPosition 1
  283. End Sub
  284. Private Sub cmdLast_Click()
  285.     SetCardPosition FlashContents.Count
  286. End Sub
  287. Private Sub cmdNext_Click()
  288.     SetCardPosition CardsPosition + 1
  289. End Sub
  290. Private Sub cmdShow_Click()
  291.     DisplayData 2
  292. End Sub
  293. Sub DisableUnusuableObjects()
  294. Dim BackwardEnabled As Boolean
  295. Dim ForwardEnabled As Boolean
  296. Dim Label As String
  297.     ChangeMode AreEntries
  298.     BackwardEnabled = Not (CardsPosition <= 1) And AreEntries
  299.     ForwardEnabled = Not (CardsPosition = FlashContents.Count) And AreEntries
  300.     cmdBack.Enabled = BackwardEnabled
  301.     cmdFirst.Enabled = BackwardEnabled
  302.     cmdNext.Enabled = ForwardEnabled
  303.     cmdLast.Enabled = ForwardEnabled
  304.     cmdShow.Enabled = Not HiddenBeingShown And AreEntries
  305.     lblCardPosition.Enabled = IsOpenFile Or AreEntries
  306.     Label = MSGSHOW
  307.     If GiveDefinition Then Label = Label & MSGWRD
  308.     If Not GiveDefinition Then Label = Label & MSGDEF
  309.     cmdShow.Caption = Label
  310. End Sub
  311. Sub DisplayCurrentCard()
  312.     ClearData
  313.     If GiveDefinition = False Then DisplayData 0
  314.     If GiveDefinition Then DisplayData 1
  315.     If HiddenBeingShown Then DisplayData 2
  316.     If Not AreEntries Then CardsPosition = 0
  317.     lblCardPosition = CardsPosition & " of " & FlashContents.Count
  318. End Sub
  319. Sub DisplayData(Data As Integer)
  320.     If Data = 0 Or Data > 1 Then txtWord = GetRevealed(CardsPosition)
  321.     If Data >= 1 Then txtDefinition = GetHidden(CardsPosition)
  322. End Sub
  323. Sub DeleteFileRecords()
  324. Dim i As Integer
  325.     On Error Resume Next
  326.     mnuFileLoadPause1.Visible = False
  327.     For i = 1 To MenuRecords
  328.         Unload mnuFileLoadRecord(i)
  329.     Next i
  330.     MenuRecords = 0
  331. End Sub
  332. Private Sub Form_Load()
  333.     GetFileRecord
  334.     If Command <> "" Then
  335.         LoadFile (Command)
  336.     End If
  337.     CDialog.InitDir = App.Path
  338.     ChangeMode (Command <> "")
  339.     DisableUnusuableObjects
  340. End Sub
  341. Public Function LoadFile(FileToOpen As String) As Boolean
  342.     LoadFile = GetFileContents(FileToOpen)
  343.     SetCardPosition 1
  344.     DisplayCurrentCard
  345.     DisableUnusuableObjects
  346. End Function
  347. Private Sub mnuDisplayOpt_Click(Index As Integer)
  348. Dim i As Integer
  349.     For i = 0 To 2
  350.         mnuDisplayOpt(i).Checked = False
  351.     Next i
  352.     mnuDisplayOpt(Index).Checked = True
  353.     HiddenBeingShown = (Index = 2)
  354.     GiveDefinition = (Index = 1)
  355.     DisableUnusuableObjects
  356.     DisplayCurrentCard
  357. End Sub
  358. Private Sub mnuDisplaySortEnt_Click(Index As Integer)
  359.     MousePointer = vbHourglass
  360.     ChangeMode 0
  361.     If Index = 0 Then SortEntries 0
  362.     If Index = 1 Then SortEntries 1
  363.     ChangeMode 1
  364.     MousePointer = 0
  365.     SetCardPosition CardsPosition
  366.     If Editor.Visible Then Editor.PrintOutEntries
  367. End Sub
  368. Private Sub mnuFileEditor_Click()
  369.     Editor.Show vbModal
  370.     If OpenFile <> "" Or FlashContents.Count > 0 Then Cards.ChangeMode True
  371.     SetCardPosition 1
  372. End Sub
  373. Private Sub mnuFileExit_Click()
  374.     End
  375. End Sub
  376. Private Sub mnuFileClose_Click()
  377.     CloseFile
  378.     ClearData
  379. End Sub
  380. Private Sub mnuFileLoadFlash_Click()
  381.     CDialog.ShowOpen
  382.     If CDialog.FileName = "" Then Exit Sub
  383.     LoadFile (CDialog.FileName)
  384. End Sub
  385. Private Sub mnuFileLoadRecord_Click(Index As Integer)
  386. Dim i As Integer
  387.     LoadedByRecord = True
  388.     SelRecord = Index
  389.     i = LoadFile(mnuFileLoadRecord(Index).Caption)
  390.     LoadedByRecord = False
  391. End Sub
  392. Sub PrepareFileEntry(MenuText As String)
  393. Dim i As Integer, j As Integer, FoundMatchingEntry As Boolean
  394.     For i = MenuRecords To 1 Step -1
  395.         If mnuFileLoadRecord(i).Caption = MenuText Then
  396.             For j = i To 1 Step -1
  397.                 mnuFileLoadRecord(j).Caption = mnuFileLoadRecord(j - 1).Caption
  398.                 FoundMatchingEntry = True
  399.             Next j
  400.         End If
  401.     Next i
  402.     If Not FoundMatchingEntry Then
  403.         If MenuRecords < MAXRECORDNUM Then
  404.             MenuRecords = MenuRecords + 1
  405.             Load mnuFileLoadRecord(MenuRecords)
  406.             mnuFileLoadRecord(MenuRecords).Visible = True
  407.         End If
  408.         For i = MenuRecords To 1 Step -1
  409.             mnuFileLoadRecord(i).Caption = mnuFileLoadRecord(i - 1).Caption
  410.         Next i
  411.     End If
  412. End Sub
  413. Sub SaveFileMenuChanges()
  414. Dim i As Integer
  415.     DeleteEntries RecentFileList
  416.     For i = 1 To MenuRecords
  417.         RecentFileList.Add mnuFileLoadRecord(i).Caption
  418.     Next i
  419.     SaveFileRecords
  420. End Sub
  421. Sub SetCardPosition(PositionNumber As Integer)
  422.     If PositionNumber < 1 Then PositionNumber = 1
  423.     If FlashContents.Count = 0 Then PositionNumber = 0
  424.     If PositionNumber > FlashContents.Count Then Exit Sub
  425.     CardsPosition = PositionNumber
  426.     DisableUnusuableObjects
  427.     DisplayCurrentCard
  428.     If cmdShow.Visible And cmdShow.Enabled Then cmdShow.SetFocus
  429. End Sub
  430. Public Sub ResetFileRecords()
  431. Dim i As Integer
  432.     DeleteFileRecords
  433.     For i = 1 To RecentFileList.Count
  434.         AddMenuRecord RecentFileList(i)
  435.     Next i
  436. End Sub
  437. Private Sub txtWord_GotFocus()
  438.     SelectAll txtWord
  439. End Sub
  440. Private Sub txtDefinition_GotFocus()
  441.     SelectAll txtDefinition
  442. End Sub
  443. Public Sub ShowStatus(Text As String)
  444.     lblStatus = Text
  445. End Sub
  446. Public Function GetStatus() As String
  447.     GetStatus = lblStatus
  448. End Function
  449.